﻿@model MvcAtletIS.Models.Performances
@{
    ViewBag.Title = "Prihlášky";
}

<h2>Prihlášky</h2>

<p>
    Pre prihlásenie na preteky využite prihlasovací formulár nižšie.<br />
    Prihlásenie na preteky pre kluby nájdete v sekcii @Html.ActionLink("Môj klub", "Index", "Signups", new { area = "MyClub" }, null). <br />
    <br />
    Zoznamy prihlásených pretekárov nájdete @Html.ActionLink("tu", "List").
</p>

<div class="error">
    @ViewBag.Status
</div>

@using (Html.BeginForm())
{   
    <fieldset>
        <legend>Prihlasovací formulár</legend>
        
        <div class="editor-label">
            Preteky
        </div>
        <div class="editor-field">
            @Html.DropDownList("CompetitionId", "Vyberte preteky")
        </div>
        
        <div class="editor-label">
            Disciplína
        </div>
        <div class="editor-field">
            @Html.DropDownList("DisciplineListId", "Vyberte disciplínu")
            @Html.ValidationMessageFor(model => model.DisciplineListId)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Surname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Surname)
            @Html.ValidationMessageFor(model => model.Surname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Birthdate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Birthdate)
            @Html.ValidationMessageFor(model => model.Birthdate)
        </div>

        <div class="editor-label">
            Krajina
        </div>
        <div class="editor-field">
            @Html.DropDownList("CountryId", "Vyberte krajinu")
            @Html.ValidationMessageFor(model => model.CountryId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Club)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Club)
            @Html.ValidationMessageFor(model => model.Club)
        </div>

        <p>
            <input type="submit" value="Prihlásiť" />
        </p>

    </fieldset>
    
}

<script type="text/javascript">
    $(document).ready(function () {
        $("#CompetitionId").change(function () {
            var idCompetition = $(this).val();
            $.getJSON("/Signups/LoadDisciplinesForCompetition", { id: idCompetition },
            function (competitorsData) {
                var select = $("#DisciplineListId");
                select.empty();
                select.append($('<option/>',
                {
                    value: null,
                    text: "Vyberte disciplínu"
                }));
                $.each(competitorsData, function (index, itemData) {
                    select.append($('<option/>',
                    {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });
            });
        });
    });
</script> 
